home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jazlib.arc / COPYFILE.DMO < prev    next >
Text File  |  1988-12-18  |  1KB  |  59 lines

  1.  
  2. /*
  3. ┌────────────────────────────────────────────────────────────────────────────┐
  4. │copyfile.dmo                                     │
  5. │Copy a file to another file. Use the command line for the file names         │
  6. │Synopsis:                                     │
  7. │  Copyfile <source> <destin> <Options>                      │
  8. │                                         │
  9. └────────────────────────────────────────────────────────────────────────────┘
  10. */
  11.  
  12. #define BUFSIZE 32767
  13.  
  14. #if DEBUG
  15.   int wsource,wdestin;
  16.   char *wbuf,*malloc();
  17.   int wnum;
  18. #endif
  19.  
  20. main(argc,argv)
  21. int argc;
  22. char **argv;
  23. {
  24.  
  25. #if ! DEBUG
  26.   int wsource,wdestin;
  27.   char *wbuf,*malloc();
  28.   int wnum;
  29. #endif
  30.  
  31.   if ((wbuf = malloc(BUFSIZE)) == 0) {
  32.     printf("\nUnable to allocate memory for copy");
  33.     exit(1);
  34.   }
  35.  
  36.   if (argc < 3) {
  37.     printf("\nUsage COPYFILE <source> <destin> <options>");
  38.     exit(1);
  39.   }
  40.  
  41.   wsource = jzopnfil(argv[1],0);
  42.   wdestin = jzcrtfil(argv[2],0);
  43.  
  44.   if ((wsource == -1) || (wdestin == -1)) {
  45.     printf("\nError on Open/Create File. Aborting...");
  46.     exit(1);
  47.   }
  48.  
  49.   do {
  50.     wnum = jzredfil(wsource,wbuf,BUFSIZE);    /* read into buffer */
  51.     if (wnum)
  52.       jzwrtfil(wdestin,wbuf,wnum);        /* write only the number read */
  53.   } while (wnum);
  54.  
  55.   jzclsfil(wdestin);
  56.   jzclsfil(wsource);
  57. }
  58.  
  59.